package com.ebring.shareEducation.controller;


import com.ebring.shareEducation.bean.Comments;
import com.ebring.shareEducation.bean.CommentsReply;
import com.ebring.shareEducation.service.CommentsService;
import com.ebring.shareEducation.service.CommentsreplyService;
import com.ebring.shareEducation.utils.RspMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class CommentsController {

    @Autowired
    private CommentsService commentsService;

    @Autowired
    private CommentsreplyService commentsreplyService;

    /**
     * 查询所有任务列表
     * @return
     */
    @PostMapping("/comments/list")
    public List<Comments> select() {
        return commentsService.selectComments();
    }

    /**
     * 修改任务
     */
       @PostMapping("/comments/update")
    public RspMsg<Comments> updateComments(Comments comments) {
           return commentsService.updateComments(comments);
    }


    /**
     * 根据任务ID删除任务
     *
     * @param commentsId 菜单id
     * @return
     */

    @PostMapping("/comments/deleteById")
    public RspMsg<Comments> deleteById(String commentsId) {
        return commentsService.deleteById(commentsId);
    }

    /**
     * 新增留言
     *
     * @param comments 菜单对象
     * @return
     */

    @PostMapping("/comments/insertMenu")
    public RspMsg<Comments> insertComments(Comments comments) {
        return commentsService.insertComments(comments);
    }



    /**
     * 新增回复
     *
     * @param commentsReply 回复对象
     * @return
     */

    @PostMapping("/Reply/insertReply")
    public RspMsg<CommentsReply> insertComments(CommentsReply commentsReply) {
        return commentsreplyService.insertreply(commentsReply);
    }
    /**
     * 查询用户下面的任务
     *
     * @param
     * @return
     */
    @PostMapping("/comments/select")
    public List<Comments> selectComments(Comments comments){
        return commentsService.selectUComments(comments);
    }




}
